LassoScript Utility
Basics Browse Detail

[Net->Listen]

Tag Link [Net->Listen] Category Networking
Type Member Source Available Yes
Support Preferred Version 7.0
Change Unchanged Data Source Any
Output Type None Security None
Implementation LCAPI Sets Lasso 8.5, Lasso 8.0, Lasso 7.0

Description

[Net->Listen] is used to place a [Net] object into TCP listening mode. The [Net->Bind] tag must be used first to establish what port the connection should listen on. The [Net->Accept] tag can then be used to accept individual incoming connections.

Syntax

<?LassoScript
Variable: 'Listener' = (Net);
$Listener->(Bind: 8000);
$Listener->(Listen);
Variable: 'Connection' = $Listener->Accept;
...
$Connection->Close;
$Listener->Close;
?>

Parameters

No Parameters Required.

Examples

To listen for incoming TCP connections:

Use the [Net] type and its member tags to establish a TCP listener. The following example listens on port 80 for incoming TCP traffic. The [Net->Accept] tag returns a new connection and the IP address of the local machine and the remote machine are reported.

[Variable: 'myListener' = (Net)]
[$myListener->(Bind: 80)]
[$myListener->(Listen)]
[Variable: 'myConnecton' = $myListener->(Accept)]
Local: [Output: $myConnection->(LocalAddress)]
Remote: [Output: $myConnection->(RemoteAddress)]
[Variable: 'Input' = $myConnection->(Read: 32768)]
...
[$myConnection->(Close)]
[$myListener->(Close)]

Local: 127.0.0.1
Remote: www.example.com